package com.jdone.compus.dto;


public class ApiResponse {
    private int code;
    private boolean success;
    private String message;
    private Object data;

    public ApiResponse() {
    }

    public ApiResponse(int code,   boolean success,  String message, Object data) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.success = success;
    }

    public static ApiResponse success(Object data) {
        return new ApiResponse(200, true, "操作成功", data);
    }

    public static ApiResponse error(String message) {
        return new ApiResponse(500, false, message, null);
    }
    public ApiResponse(boolean success, String message) {
        this.code = 500;
        this.success = success;
        this.message = message;
    }

    public ApiResponse(boolean success, String message, Object data) {
        this.code = 200;
        this.success = success;
        this.message = message;
        this.data = data;
    }

    // Getters and setters
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }


}

